package com.atguigu.ggkt.vod.controller;


import com.atguigu.ggkt.result.Result;
import com.atguigu.ggkt.model.vod.Video;
import com.atguigu.ggkt.vod.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author sleephardzz
 * @since 2023-07-10
 */
@RestController
@RequestMapping(value="/admin/vod/video")
//@CrossOrigin
public class VideoController {
    @Autowired
    private VideoService videoService;

    //2添加小节
    @PostMapping("save")
    public Result save(@RequestBody Video video){
        videoService.save(video);
        return Result.ok(null);
    }

    //3根据id查询
    @GetMapping("get/{id}")
    public Result get(@PathVariable Long id){
        Video video = videoService.getById(id);
        return Result.ok(video);
    }

    //4修改实现
    @PostMapping("update")
    public Result update(@RequestBody Video video){
        boolean success = videoService.updateById(video);
        return Result.ok(success);
    }
    //5删除
    @DeleteMapping("remove/{id}")
    public Result remove(@PathVariable Long id){
        videoService.removeVideoById(id);//删除视频小节，进行完善
        return Result.ok(null);
    }

}

